import API from "@/common/config/api.js"
import {
	msg
} from "@/common/function/system_fun.js"

//需要绑定手机号(伪登录)的路由
const needLoginArr = [

]
//登录
export const wx_login = (callback) => {
	uni.login({
		success: (e) => {
			var invite_id = uni.getStorageSync('invite_id') || ''
			API.getJson('users_miniLogin', {
				code: e.code,
				invite_id: invite_id
			}).then((res) => {
				console.log("用户信息",res);
				uni.hideLoading()
				if(res.code == 1){
					let info = res.data
					uni.setStorageSync('token', info.token)
					uni.setStorageSync('user_id', info.user_id)
					get_userInfo(callback)
				}
			})
		}
	})
}

//获取用户信息
export const get_userInfo = (callback) => {
	API.getJson('users_userInfo', {}).then((res) => {
		if(res.code == 1){
			let info = res.data
			uni.setStorageSync('user_info', info)
			if (typeof callback == 'function') {
				callback(info)
			}
		}
	})
}

//获取县区列表
export const getAreaList = (params)=>{
	return API.getJson('getAreaList',params)
}

//获取酒店列表
export const getHotelList = (params) => {
	return API.getJson('marchant_get_list', params);
}

//获取酒店详情
export const getDetailFun = (params)=>{
	return API.getJson('getDetailFun',params)
}

//获取酒店房型列表
export const getHotelDetail = (params) => {
	return API.getJson('getHotelDetail', params);
}
//获取酒店照片列表 
export const getHotelPic = (params) => {
	return API.postJson('getHotelPic', params);
}
//获取酒店信息
export const getHotelInfo = (params) => {
	return API.postJson('getHotelInfo', params);
}

//获取酒店房间信息
export const getHotelRoomInfo = (params) => {
	return API.postJson('getHotelRoomInfo', params);
}
//计算订单价格
export const calcOrderPrice = (params) => {
	return API.postJson('calcOrderPrice', params);
}
//下单
export const addOrder = (params) => {
	return API.postJson('addOrder', params);
}
//发起支付
export const pay = (params) => {
	return API.postJson('pay', params);
}
//获取订单列表
export const getOrdersList = (params) => {
	return API.postJson('getOrdersList', params);
}
//获取订单信息
export const getOrdersInfo = (params) => {
	return API.postJson('getOrdersInfo', params);
}
//取消订单
export const cancelOrders = (params) => {
return API.postJson('cancelOrders', params);
}
//登录
export const mpLogin = (params) => {
	return API.postJson('mp_login', params);
}
//登录
export const updateUserInfo = (params) => {
	return API.postJson('updateUserInfo', params);
}

//获取banner图
export const getBannerListFun = ()=>{
	return API.getJson('getBannerList',{})
}

//评价
export const setOrderEvalFun = (params={})=>{
	return API.getJson('setOrderEval',params)
}

//评价列表
export const getHouseCommentListFun = (params={})=>{
	return API.getJson('getHouseCommentList',params)
}

